.class public Lorg/microemu/microedition/io/ConnectionInvocationHandler;
.super Ljava/lang/Object;
.source "ConnectionInvocationHandler.java"

# interfaces
.implements Ljava/lang/reflect/InvocationHandler;


# static fields
.field static class$org$microemu$microedition$io$ConnectionInvocationHandler:Ljava/lang/Class;


# instance fields
.field private acc:Ljava/security/AccessControlContext;

.field private originalConnection:Ljavax/microedition/io/Connection;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 56
    sget-object v0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->class$org$microemu$microedition$io$ConnectionInvocationHandler:Ljava/lang/Class;

    if-nez v0, :cond_0

    const-string v0, "org.microemu.microedition.io.ConnectionInvocationHandler"

    invoke-static {v0}, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->class$(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v0

    sput-object v0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->class$org$microemu$microedition$io$ConnectionInvocationHandler:Ljava/lang/Class;

    :goto_0
    invoke-static {v0}, Lorg/microemu/log/Logger;->addLogOrigin(Ljava/lang/Class;)V

    .line 57
    return-void

    .line 56
    :cond_0
    sget-object v0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->class$org$microemu$microedition$io$ConnectionInvocationHandler:Ljava/lang/Class;

    goto :goto_0
.end method

.method public constructor <init>(Ljavax/microedition/io/Connection;Z)V
    .locals 1
    .parameter "con"
    .parameter "needPrivilegedCalls"

    .prologue
    .line 59
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 60
    iput-object p1, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->originalConnection:Ljavax/microedition/io/Connection;

    .line 61
    if-eqz p2, :cond_0

    .line 62
    invoke-static {}, Ljava/security/AccessController;->getContext()Ljava/security/AccessControlContext;

    move-result-object v0

    iput-object v0, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->acc:Ljava/security/AccessControlContext;

    .line 64
    :cond_0
    return-void
.end method

.method static access$000(Lorg/microemu/microedition/io/ConnectionInvocationHandler;)Ljavax/microedition/io/Connection;
    .locals 1
    .parameter "x0"

    .prologue
    .line 48
    iget-object v0, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->originalConnection:Ljavax/microedition/io/Connection;

    return-object v0
.end method

.method static class$(Ljava/lang/String;)Ljava/lang/Class;
    .locals 2
    .parameter "x0"

    .prologue
    .line 56
    :try_start_0
    invoke-static {p0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
    :try_end_0
    .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    return-object v1

    :catch_0
    move-exception v0

    .local v0, x1:Ljava/lang/ClassNotFoundException;
    new-instance v1, Ljava/lang/NoClassDefFoundError;

    invoke-direct {v1}, Ljava/lang/NoClassDefFoundError;-><init>()V

    invoke-virtual {v1, v0}, Ljava/lang/NoClassDefFoundError;->initCause(Ljava/lang/Throwable;)Ljava/lang/Throwable;

    move-result-object v1

    throw v1
.end method


# virtual methods
.method public invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;
    .locals 4
    .parameter "proxy"
    .parameter "method"
    .parameter "args"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Throwable;
        }
    .end annotation

    .prologue
    const-string v3, "Connection."

    .line 70
    sget-boolean v1, Lorg/microemu/microedition/io/ConnectorImpl;->debugConnectionInvocations:Z

    if-eqz v1, :cond_0

    .line 71
    const-string v1, "invoke"

    invoke-static {v1, p2}, Lorg/microemu/log/Logger;->debug(Ljava/lang/String;Ljava/lang/Object;)V

    .line 74
    :cond_0
    :try_start_0
    iget-object v1, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->acc:Ljava/security/AccessControlContext;

    if-eqz v1, :cond_1

    .line 75
    new-instance v1, Lorg/microemu/microedition/io/ConnectionInvocationHandler$1;

    invoke-direct {v1, p0, p2, p3}, Lorg/microemu/microedition/io/ConnectionInvocationHandler$1;-><init>(Lorg/microemu/microedition/io/ConnectionInvocationHandler;Ljava/lang/reflect/Method;[Ljava/lang/Object;)V

    iget-object v2, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->acc:Ljava/security/AccessControlContext;

    invoke-static {v1, v2}, Ljava/security/AccessController;->doPrivileged(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;

    move-result-object v1

    .line 81
    :goto_0
    return-object v1

    :cond_1
    iget-object v1, p0, Lorg/microemu/microedition/io/ConnectionInvocationHandler;->originalConnection:Ljavax/microedition/io/Connection;

    invoke-virtual {p2, v1, p3}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/security/PrivilegedActionException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_1

    move-result-object v1

    goto :goto_0

    .line 83
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 84
    .local v0, e:Ljava/security/PrivilegedActionException;
    invoke-virtual {v0}, Ljava/security/PrivilegedActionException;->getCause()Ljava/lang/Throwable;

    move-result-object v1

    instance-of v1, v1, Ljava/lang/reflect/InvocationTargetException;

    if-eqz v1, :cond_3

    .line 85
    sget-boolean v1, Lorg/microemu/microedition/io/ConnectorImpl;->debugConnectionInvocations:Z

    if-eqz v1, :cond_2

    .line 86
    new-instance v1, Ljava/lang/StringBuffer;

    invoke-direct {v1}, Ljava/lang/StringBuffer;-><init>()V

    const-string v2, "Connection."

    invoke-virtual {v1, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {p2}, Ljava/lang/reflect/Method;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0}, Ljava/security/PrivilegedActionException;->getCause()Ljava/lang/Throwable;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/Throwable;->getCause()Ljava/lang/Throwable;

    move-result-object v2

    invoke-static {v1, v2}, Lorg/microemu/log/Logger;->error(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 88
    :cond_2
    invoke-virtual {v0}, Ljava/security/PrivilegedActionException;->getCause()Ljava/lang/Throwable;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/Throwable;->getCause()Ljava/lang/Throwable;

    move-result-object v1

    throw v1

    .line 90
    :cond_3
    sget-boolean v1, Lorg/microemu/microedition/io/ConnectorImpl;->debugConnectionInvocations:Z

    if-eqz v1, :cond_4

    .line 91
    new-instance v1, Ljava/lang/StringBuffer;

    invoke-direct {v1}, Ljava/lang/StringBuffer;-><init>()V

    const-string v2, "Connection."

    invoke-virtual {v1, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {p2}, Ljava/lang/reflect/Method;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0}, Ljava/security/PrivilegedActionException;->getCause()Ljava/lang/Throwable;

    move-result-object v2

    invoke-static {v1, v2}, Lorg/microemu/log/Logger;->error(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 93
    :cond_4
    invoke-virtual {v0}, Ljava/security/PrivilegedActionException;->getCause()Ljava/lang/Throwable;

    move-result-object v1

    throw v1

    .line 95
    .end local v0           #e:Ljava/security/PrivilegedActionException;
    :catch_1
    move-exception v1

    move-object v0, v1

    .line 96
    .local v0, e:Ljava/lang/reflect/InvocationTargetException;
    sget-boolean v1, Lorg/microemu/microedition/io/ConnectorImpl;->debugConnectionInvocations:Z

    if-eqz v1, :cond_5

    .line 97
    new-instance v1, Ljava/lang/StringBuffer;

    invoke-direct {v1}, Ljava/lang/StringBuffer;-><init>()V

    const-string v2, "Connection."

    invoke-virtual {v1, v3}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {p2}, Ljava/lang/reflect/Method;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Ljava/lang/StringBuffer;->append(Ljava/lang/String;)Ljava/lang/StringBuffer;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuffer;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0}, Ljava/lang/reflect/InvocationTargetException;->getCause()Ljava/lang/Throwable;

    move-result-object v2

    invoke-static {v1, v2}, Lorg/microemu/log/Logger;->error(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 99
    :cond_5
    invoke-virtual {v0}, Ljava/lang/reflect/InvocationTargetException;->getCause()Ljava/lang/Throwable;

    move-result-object v1

    throw v1
.end method
